#!/usr/bin/env perl
use strict;
use warnings;
use diagnostics;
use utf8;
use Readonly;

use Test::More;
use Test::Mojo;

use lib "$ENV{SKAL_ROOT}/lib";
use lib "$ENV{SKAL_ROOT}/tests-lib";
use TestLib;

Readonly(my $USER_CONF_LINK => 'html:root > body:last-child > div:only-child[class="container"] > div:first-child[class="header"] > div:last-child[class="user_info"] > p:only-child > a:only-child[href="/conf?section=user"][title="Configuration - User"]');
# Complete path to the element with link for the 'Configuration - User'
#   section placed in the header of every Skal page

my $t = Test::Mojo->new('Skal');

test_get_401($t, @TestLib::PATHS);

test_get_401_badauth($t, @TestLib::PATHS);

$t->get_ok("//testuser:$TestLib::tup\@$_")
  ->status_is(200)
  ->content_type_like(qr'text/html'xms)
  ->element_exists($USER_CONF_LINK)
  ->text_is($USER_CONF_LINK => 'testuser') 
    foreach (@TestLib::PATHS);

test_get_401_badauth($t, reverse @TestLib::PATHS);

test_get_401($t, reverse @TestLib::PATHS);

done_testing();

